package com.topInterview;

/**
 * @Author: huangzhigao
 * @Date: 2022/2/19 17:22
 */
public class Leecode36_validShudu {
    public boolean isValidSudoku(char[][] board) {

        int[][] row = new int[9][10];
        int[][] col = new int[9][10];
        int[][] boxs = new int[9][10];
        for (int i = 0; i < 9; i++) {
            for (int j = 0; j < 9; j++) {
                if (board[i][j] != '.') {
                    int val = board[i][j] - '0';
                    int box = 3 * (i / 3) + (j / 3);
                    if (row[i][val]++ > 0 || col[j][val]++ > 0 || boxs[box][val]++ > 0) {
                        return false;
                    }
                }

            }
        }
        return true;
    }


}
